package com.yang.leather.admin.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yang.leather.admin.dao.IProdTypeDao;
import com.yang.leather.admin.pojo.ProdType;
import com.yang.leather.admin.service.IProdTypeService;
import com.yang.leather.core.LeatherCoreServiceImpl;

@Service("prodTypeService")
@Transactional
public class ProdTypeServiceImpl extends LeatherCoreServiceImpl<ProdType> implements IProdTypeService{
	
	private IProdTypeDao prodTypeDao;
	
	public List<ProdType> getAllProdTypes() {
		return prodTypeDao.findAll();
	}

	public void saveProdType(ProdType type) {
		prodTypeDao.save(type);
	}

	public void updateProdType(ProdType type) {
		prodTypeDao.saveOrUpdate(type);
	}
	
	public void deleteProdType(Long typeId) {
		this.getDao().deleteById(typeId);
	}

	public void deleteProdTypes(List<Long> typeIds) {
		for(Long typeId : typeIds){
			this.getDao().deleteById(typeId);
		}
	}

	
	public IProdTypeDao getProdTypeDao() {
		return prodTypeDao;
	}

	@Autowired
	public void setProdTypeDao(@Qualifier("prodTypeDao")
			IProdTypeDao prodTypeDao) {
		this.prodTypeDao = prodTypeDao;
	}

	@Autowired
	public void setDao(@Qualifier("prodTypeDao")
			IProdTypeDao dao){
		super.setDao(dao);
	}
	
	public IProdTypeDao getDao(){
		return (IProdTypeDao)super.getDao();
	}
	
}
